doctype html
html
    head
        title= title
        meta(http-equiv="Content-Type", content="text/html; charset=utf-8")
        link(rel='stylesheet', href='/stylesheets/style.css')
        script(src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js")
        script(src='/socket.io/socket.io.js')
        script.
            $(function(){
                var iosocket = io.connect('http://localhost:8855/');

                iosocket.on('connect', function () {
                    $('#incomingChatMessages').append($('<li>Connected</li>'));

                    iosocket.on('message', function(message) {
                        $('#incomingChatMessages').append($('<li></li>').text(message));
                    });
                    iosocket.on('disconnect', function() {
                        $('#incomingChatMessages').append('<li>Disconnected</li>');
                    });
                });

                $('#outgoingChatMessage').keypress(function(event) {
                    if(event.which == 13) {
                        event.preventDefault();
                        iosocket.send($('#outgoingChatMessage').val());
                        $('#incomingChatMessages').append($('<li></li>').text($('#outgoingChatMessage').val()));
                        $('#outgoingChatMessage').val('');
                    }
                });

                $('#submit_btn').click(function() {
                    iosocket.send($('#outgoingChatMessage').val());
                    $('#incomingChatMessages').append($('<li></li>').text($('#outgoingChatMessage').val()));
                    $('#outgoingChatMessage').val('');
                });

            });
    body
        block content